from selenium import webdriver
from bs4 import BeautifulSoup
import requests
import re
import os
class Spider:
    def __init__(self):
        self.page=2
        self.switch=True
    def loadPage(self, page):
        """
        :param page:
        :return:
        下载页面
        """
        wd = webdriver.Chrome(r'd:\chromedriver.exe')
        if (page==1):
            url = "https://www.51miz.com/sound/"
        else:
            url = "https://www.51miz.com/sound/p_"+str(page)+"/"


        wd.get(url)
        #wb_data = requests.get(url)
        # wb_data=wd.page_source()
        wb_data=wd.page_source

       # soup = BeautifulSoup(wb_data.text, 'html.parser')
        soup = BeautifulSoup(wb_data, 'html.parser')
        titles = soup.find_all('source')
        self.dealPage(titles)
        print(titles)
    def dealPage(self,titles):
        str = "http:"
        re = []
        for title in titles:
            title = str + title.attrs['src']
            re.append(title)
        print(title)


if __name__== "__main__":
    SpiderS=Spider()
    SpiderS.loadPage(page=2)
